package com.star.book.controller.system;

import com.star.book.entity.BookType;
import com.star.book.entity.User;
import com.star.book.service.IBookTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 小说类型
 * */
@Controller
public class SysBookTypeController {
    @Autowired
    private IBookTypeService bookTypeService;

    @GetMapping("/sys/bookType")
    public String bookType(Model m, @RequestParam Integer id){
        User user = SysUserInfo.loginInfo();
        m.addAttribute("user",user);
        Map<String, Object> stringObjectMap = bookTypeService.bookTypeMap(id);
        Integer page = (Integer) stringObjectMap.get("page");
        m.addAttribute("page",page);
        List<BookType> bookTypeByPage = (List<BookType>) stringObjectMap.get("bookTypeByPage");
        m.addAttribute("bookType",bookTypeByPage);
        return "system/bookType";
    }
}
